export function cachepromise<
    T extends (arg: string) => Promise<R>,
    R extends any
>(fn: T): T {
    const sourcecache = new Map<string, Promise<R>>();
    return (async (key: string): Promise<R> => {
        const found = sourcecache.get(key);
        if (found) {
            return found;
        }
        const loadpro = fn(key);
        sourcecache.set(key, loadpro);
        return loadpro;
    }) as T;
}
